﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FixedControl.cs" company="Marcelo Roca">
//   Copyright (c) 2011 Marcelo Roca. All rights reserved.
// </copyright>
// <author name="Marcelo Roca" email="marce@marceloroca.com"/>
// <license>
//   This program is free software: you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation, either version 3 of the License, or
//   (at your option) any later version.
// 
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program.  If not, see http://www.gnu.org/licenses/.
// </license>
// --------------------------------------------------------------------------------------------------------------------

namespace GameKits.Unity.GuiForms.Controls
{
    using UnityEngine;

    public abstract class FixedControl : Control
    {
        /// <summary>
        /// La posición del control
        /// </summary>
        private Position position = Position.Zero;

        /// <summary>
        /// El tamaño del control
        /// </summary>
        private Size size = Size.Zero;

        /// <summary>
        /// Gets or sets Position.
        /// </summary>
        /// <remarks>
        /// Position on the screen to use for the box.
        /// </remarks>
        public Position Position
        {
            get
            {
                return this.position;
            }

            set
            {
                if (this.position != value)
                {
                    this.position = value;
                    this.IsDirty = true;
                }
            }
        }

        /// <summary>
        /// Gets or sets Height.
        /// </summary>
        public Size Size
        {
            get
            {
                return this.size;
            }

            set
            {
                if (this.size != value)
                {
                    this.size = value;
                    this.IsDirty = true;
                }
            }
        }

        /// <summary>
        /// Gets PositionRect for GUI.
        /// </summary>
        /// <remarks>
        /// Rectangle on the screen to use for the box.
        /// </remarks>
        protected Rect PositionRect
        {
            get;
            private set;
        }

        /// <summary>
        /// Calculams el tamaño y posicion del control
        /// </summary>
        protected override void DoOnLayout()
        {
            this.PositionRect = new Rect(this.Position.X, this.Position.Y, this.Size.Width, this.Size.Height);
            base.DoOnLayout();
        }
    }
}
